class Solution(object):
    def maximumCandies(self, candies, k):
        total = sum(candies)
        right = total // k
        left = 1
        def cal(val):
            ans = 0
            for c in candies:
                ans += c // val
            return ans >= k
        while left < right:
            mid = (left + right + 1) // 2
            if cal(mid):
                left = mid
            else:
                right = mid - 1
        return right